package com.ithinks.flow.common.utils.system;
import java.io.Serializable;
import java.util.Properties;

/**
 * @Description
 * @ClassName SystemUtils
 * @Author MR.LI
 * @date 2020.11.19 18:21
 */
public class SystemUtils implements Serializable {


    private static final long serialVersionUID = 1L;

    /**
     * Java 运行时环境规范名称的KEY
     */
    public final static String SPECIFICATION_NAME = SystemConstantKeys.SPECIFICATION_NAME;
    /**
     * Java 运行时环境版本的KEY
     */
    public final static String VERSION = SystemConstantKeys.VERSION;
    /**
     * Java 运行时环境规范版本的KEY
     */
    public final static String SPECIFICATION_VERSION = SystemConstantKeys.SPECIFICATION_VERSION;
    /**
     * Java 运行时环境供应商的KEY
     */
    public final static String VENDOR = SystemConstantKeys.VENDOR;
    /**
     * Java 运行时环境规范供应商的KEY
     */
    public final static String SPECIFICATION_VENDOR = SystemConstantKeys.SPECIFICATION_VENDOR;
    /**
     * Java 供应商的 URL的KEY
     */
    public final static String VENDOR_URL = SystemConstantKeys.VENDOR_URL;
    /**
     * Java 安装目录的KEY
     */
    public final static String HOME = SystemConstantKeys.HOME;
    /**
     * 加载库时搜索的路径列表的KEY
     */
    public final static String LIBRARY_PATH = SystemConstantKeys.LIBRARY_PATH;
    /**
     * 默认的临时文件路径的KEY
     */
    public final static String TMPDIR = SystemConstantKeys.TMPDIR;
    /**
     * 要使用的 JIT 编译器的名称的KEY
     */
    public final static String COMPILER = SystemConstantKeys.COMPILER;
    /**
     * 一个或多个扩展目录的路径的KEY
     */
    public final static String EXT_DIRS = SystemConstantKeys.EXT_DIRS;

    // ----- Java虚拟机信息 -----/
    /**
     * Java 虚拟机实现名称的KEY
     */
    public final static String VM_NAME = SystemConstantKeys.VM_NAME;
    /**
     * Java 虚拟机规范名称的KEY
     */
    public final static String VM_SPECIFICATION_NAME = SystemConstantKeys.VM_SPECIFICATION_NAME;
    /**
     * Java 虚拟机实现版本的KEY
     */
    public final static String VM_VERSION = SystemConstantKeys.VM_VERSION;
    /**
     * Java 虚拟机规范版本的KEY
     */
    public final static String VM_SPECIFICATION_VERSION = SystemConstantKeys.VM_SPECIFICATION_VERSION;
    /**
     * Java 虚拟机实现供应商的KEY
     */
    public final static String VM_VENDOR = SystemConstantKeys.VM_VENDOR;
    /**
     * Java 虚拟机规范供应商的KEY
     */
    public final static String VM_SPECIFICATION_VENDOR = SystemConstantKeys.VM_SPECIFICATION_VENDOR;

    // ----- Java类信息 -----/
    /**
     * Java 类格式版本号的KEY
     */
    public final static String CLASS_VERSION = SystemConstantKeys.CLASS_VERSION;
    /**
     * Java 类路径的KEY
     */
    public final static String CLASS_PATH = SystemConstantKeys.CLASS_PATH;

    // ----- OS信息 -----/
    /**
     * 操作系统的名称的KEY
     */
    public final static String OS_NAME = SystemConstantKeys.OS_NAME;
    /**
     * 操作系统的架构的KEY
     */
    public final static String OS_ARCH = SystemConstantKeys.OS_ARCH;
    /**
     * 操作系统的版本的KEY
     */
    public final static String OS_VERSION = SystemConstantKeys.OS_VERSION;
    /**
     * 文件分隔符（在 UNIX 系统中是“/”）的KEY
     */
    public final static String FILE_SEPARATOR = SystemConstantKeys.FILE_SEPARATOR;
    /**
     * 路径分隔符（在 UNIX 系统中是“:”）的KEY
     */
    public final static String PATH_SEPARATOR = SystemConstantKeys.PATH_SEPARATOR;
    /**
     * 行分隔符（在 UNIX 系统中是“\n”）的KEY
     */
    public final static String LINE_SEPARATOR = SystemConstantKeys.LINE_SEPARATOR;

    // ----- 用户信息 -----/
    /**
     * 用户的账户名称的KEY
     */
    public final static String USER_NAME = SystemConstantKeys.USER_NAME;
    /**
     * 用户的主目录的KEY
     */
    public final static String USER_HOME = SystemConstantKeys.USER_HOME;
    /**
     * 用户的当前工作目录的KEY
     */
    public final static String USER_DIR = SystemConstantKeys.USER_DIR;



    public static String getValue(String name,boolean quiet){

        String value= null;

        try{
            value = System.getProperty(name);

        }catch (SecurityException e){
            if(false == quiet)
            {
                System.out.println("SecurityException reading the system property "+ name);
            }
        }

        if (null == value) {
            try {
                value = System.getenv(name);
            } catch (SecurityException e) {
                if (false == quiet) {
                    System.out.println("SecurityException reading the system env"+ name);
                }
            }
        }
        return value;


    }

    public static Properties getProp ()
    {
        return System.getProperties();
    }


}
